/* 
 * File:   pic24e_timer.h
 * Author: apleilx
 *
 * Created on 2015?9?3?, ??9:59
 */

#ifndef PIC24E_TIMER_H
#define	PIC24E_TIMER_H

#ifdef	__cplusplus
extern "C" {
#endif

#include "stdint.h"
    
#ifdef   _TIMER_MODULE_
#define  TIM_EXT
#else
#define  TIM_EXT  extern
#endif      
    
#define SYSTICK_CYCLE              1                                            //system tick timer interrupt cycle 
#define COUNTER_10MS              (10/SYSTICK_CYCLE)
#define COUNTER_50MS              (50/SYSTICK_CYCLE)
#define COUNTER_100MS             (100/SYSTICK_CYCLE)
#define COUNTER_125MS             (125/SYSTICK_CYCLE)
#define COUNTER_250MS             (250/SYSTICK_CYCLE)
#define COUNTER_500MS             (500/SYSTICK_CYCLE)
#define COUNTER_11S                (1000/SYSTICK_CYCLE)
#define COUNTER_1S                (1000/SYSTICK_CYCLE)
#define COUNTER_2S                (2000/SYSTICK_CYCLE)
#define COUNTER_3S                (8000/SYSTICK_CYCLE)
#define COUNTER_5S                (5000/SYSTICK_CYCLE)
#define COUNTER_10S               (10000/SYSTICK_CYCLE)
#define COUNTER_60S               (60000/SYSTICK_CYCLE)

TIM_EXT  uint16_t Counter_10ms;
TIM_EXT  uint16_t Counter_50ms;
TIM_EXT  uint16_t Counter_100ms;
TIM_EXT  uint16_t Counter_125ms;
TIM_EXT  uint16_t Counter_250ms;
TIM_EXT  uint16_t Counter_500ms;
TIM_EXT  uint16_t Counter_11s;
TIM_EXT  uint16_t Counter_1s;
TIM_EXT  uint16_t Counter_2s;
TIM_EXT  uint16_t Counter_3s;
TIM_EXT  uint16_t Counter_5s;
TIM_EXT  uint16_t Counter_10s;
TIM_EXT  uint16_t Counter_60s;

TIM_EXT  uint8_t bPulse_10ms ;
TIM_EXT  uint8_t bPulse_50ms ;
TIM_EXT  uint8_t bPulse_100ms ;
TIM_EXT  uint8_t bPulse_125ms  ;
TIM_EXT  uint8_t bPulse_250ms  ;
TIM_EXT  uint8_t bPulse_500ms  ;
TIM_EXT  uint8_t bPulse_11s ;
TIM_EXT  uint8_t bPulse_1s ;
TIM_EXT  uint8_t bPulse_2s ;
TIM_EXT  uint8_t bPulse_3s ;
TIM_EXT  uint8_t bPulse_5s ;
TIM_EXT  uint8_t bPulse_10s  ;
TIM_EXT  uint8_t bPulse_60s  ;
TIM_EXT  uint8_t bPulseSysTick  ;

TIM_EXT volatile uint16_t SysTickCnt;
TIM_EXT volatile uint32_t SysTickIntCnt;
TIM_EXT uint32_t  PowerUpTimeCnt;

void SysTickInit(void);
void SysPulseCreat(void);
void SysPulseClear(void);
void SysTimerCounterClear(void);
void TickIntHook(void);


#undef TIM_EXT


#ifdef	__cplusplus
}
#endif

#endif	/* PIC24E_TIMER_H */

